package com.s69.gyh.mybatisplus_demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.s69.gyh.mybatisplus_demo.dao.StudentDao;
import com.s69.gyh.mybatisplus_demo.entity.Student;
import com.s69.gyh.mybatisplus_demo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> implements StudentService {
    @Override
    public Page getPage(Page page,String stuName, Integer pageNum) {
        LambdaQueryWrapper<Student> queryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.hasText(stuName)) {
            queryWrapper.like(Student::getStudentname, stuName);
        }
        queryWrapper.orderByDesc(Student::getId);
        return this.page(page, queryWrapper);

    }
}
